import { ItemInfo } from "../../../resource/info/ItemInfo";
import { ECategory } from "../../../../../Message/Public/ECategory";
import { EProp } from "../../../../../Message/Public/EProp";
import { EBind } from "../../../../../Message/Public/EBind";
import { SkillConfig } from "../../../resource/SkillConfig";
import { SPetInfo } from "../../../../../Message/Game/SPetInfo";
import { PetColor } from "./PetColor";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { EPetStatus } from "../../../../../Message/Game/EPetStatus";
import { ShopItemInfo } from "../../../resource/info/ShopItemInfo";
import { ShopConfig } from "../../../resource/ShopConfig";
import { TItemPet } from "../../../../../Message/Db/Tables/TItemPet";
import { PetConfig } from "../../../resource/PetConfig";
import { TCareer } from "../../../../../Message/Db/Tables/TCareer";
import { CareerConfig } from "../../../resource/CareerConfig";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ItemData } from "../../../resource/info/ItemData";
import { SPetSkill } from "../../../../../Message/Game/SPetSkill";
import { TPetUpgrage } from "../../../../../Message/Db/Tables/TPetUpgrage";
import { PetUpgradeConfig } from "../../../resource/PetUpgradeConfig";
import { ColorConfig } from "../../../resource/ColorConfig";
import { EPetUpgradeType } from "../../../../../Message/Game/EPetUpgradeType";
import { PetUpgradeModelConfig } from "../../../resource/PetUpgradeModelConfig";
import { EPetGrowthGrade } from "../../../../../Message/Game/EPetGrowthGrade";
import { TPetUpgradeModel } from "../../../../../Message/Db/Tables/TPetUpgradeModel";
import { ItemConfig } from "../../../resource/ItemConfig";
import { ECareer } from "../../../../../Message/Public/ECareer";
import { SPlayerItem } from "../../../../../Message/Public/SPlayerItem";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { PetAttrCalcUtil } from "./PetAttrCalcUtil";
import { SFightAttribute } from "../../../../../Message/Public/SFightAttribute";
import { ToolTipInfo } from "../../../model/ToolTipInfo";
import { Tooltip } from "../../common/tooltip/Tooltip";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { PlayerEqStrengthInfo } from "../../player/equip/PlayerEqStrengthInfo";
import { Cache } from "../../../cache/Cache";
import { PetBloodLineConfig } from "../../../resource/PetBloodLineConfig";
import { EquipmentUtil } from "../../common/util/EquipmentUtil";
import { DefInfo } from "../../../resource/info/DefInfo";
import { EActiveType } from "../../../../../Message/Public/EActiveType";
import { JSONHelper } from "../../../../../com/mui/serialization/json/JSONHelper";
import { SPetBlood } from "../../../../../Message/Game/SPetBlood";
type int = number;
//class PetUtil
    
    export  class PetUtil
    {
        

        public static isSpecialPetSkillBookDraw(arg1: ItemInfo): Boolean
        {
            return arg1.item.category == ECategory._ECategoryProp && arg1.item.type == EProp._EPropSkillPetBook && arg1.item.bind == EBind._EBindNo && SkillConfig.instance.isSpecialBookSkill(arg1.item.effect);
        }

        
        {
            PetUtil.curUseBloodItemCode = 0;
            PetUtil.otherEquipments = [];
            PetUtil.selfEquipments = [];
        }

        public static getPetName(arg1: SPetInfo, arg2: Boolean=false): string
        {
            var loc2=null;
            var loc3=null;
            var loc1="";
            if (arg1) 
            {
                loc3 = PetColor.getTalentColor(arg1);
                loc2 = arg1.name;
                if (arg2 && loc2.length > 4) 
                {
                    loc2 = loc2.substr(0, 4);
                }
                loc1 = HTMLUtil.addColor(loc2, loc3.color);
            }
            return loc1;
        }

        public static isBattled(arg1: SPetInfo): Boolean
        {
            var loc1=false;
            if (arg1) 
            {
                if (!(arg1.status == EPetStatus._EPetRest) && !(arg1.status == EPetStatus._EPetSire) && !(arg1.status == EPetStatus._EPetEquip) && !(arg1.status == EPetStatus._EpetTrain)) 
                {
                    loc1 = true;
                }
            }
            return loc1;
        }

        public static isCanExplore(arg1: SPetInfo): Boolean
        {
            return PetUtil.getFourDigitLevel(arg1.reinLevel, arg1.level) >= 55 && !(arg1.status == EPetStatus._EpetTrain) && arg1.isBorrow == false;
        }

        public static getShopItemInfoByGrowth(arg1: int): ShopItemInfo
        {
            var loc1=null;
            var loc2=0;
            if (arg1 >= 20 && arg1 <= 31) 
            {
                loc2 = 14019200;
            }
            else if (arg1 >= 32 && arg1 <= 47) 
            {
                loc2 = 14019300;
            }
            else if (arg1 >= 48 && arg1 <= 63) 
            {
                loc2 = 14019400;
            }
            else if (arg1 >= 64 && arg1 <= 100) 
            {
                loc2 = 14019500;
            }
            loc1 = ShopConfig.instance.getShopItemInfoByCode(loc2);
            return loc1;
        }

        public static getShopItemInfoBySpirit(arg1: int): ShopItemInfo
        {
            var loc1=null;
            var loc2=0;
            if (arg1 >= 0 && arg1 <= 2) 
            {
                loc2 = 14020200;
            }
            else if (arg1 >= 3 && arg1 <= 5) 
            {
                loc2 = 14020300;
            }
            else if (arg1 >= 6 && arg1 <= 9) 
            {
                loc2 = 14020400;
            }
            loc1 = ShopConfig.instance.getShopItemInfoByCode(loc2);
            return loc1;
        }

        public static getTItemPet(arg1: SPetInfo): TItemPet
        {
            var loc1=null;
            if (arg1) 
            {
                loc1 = PetConfig.instance.getInfoByCode(arg1.code);
            }
            return loc1;
        }

        public static getPetTCareer(arg1: SPetInfo): TCareer
        {
            var loc1=null;
            if (arg1) 
            {
                loc1 = CareerConfig.instance.getInfoByCode(arg1.career);
            }
            return loc1;
        }

        public static getLabelToolTipData(arg1: int): string
        {
            var loc1="";
            if (arg1 != 0) 
            {
                if (arg1 == 1) 
                {
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(54101), GlobalStyle.color6);
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(54102), "#ffffff");
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(54103), "#ffffff");
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(54104), GlobalStyle.color5);
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(54105), GlobalStyle.color1);
                }
            }
            else 
            {
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54096), GlobalStyle.color6);
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54097), "#ffffff");
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54098), "#ffffff");
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54099), GlobalStyle.color4);
                loc1 = loc1 + HTMLUtil.addColor(Language.getString(54100), GlobalStyle.color1);
            }
            return loc1;
        }

        public static getLifeSpanByEgg(arg1: ItemData): int
        {
            var loc2=0;
            var loc3=0;
            var loc1=10;
            if (arg1) 
            {
                if ((loc3 = arg1.itemInfo.item.itemLevel) != 2) 
                {
                    if (loc3 != 3) 
                    {
                        if (loc3 == 4) 
                        {
                            loc1 = 2000;
                        }
                    }
                    else 
                    {
                        loc1 = 400;
                    }
                }
                else 
                {
                    loc1 = 50;
                }
            }
            return loc1;
        }

        public static getGiftSkill(arg1: SPetInfo): SPetSkill
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            if (arg1) 
            {
                loc3 = 0;
                while (loc3 < arg1.skills.length) 
                {
                    loc2 = arg1.skills[loc3];
                    if (loc2.isGift) 
                    {
                        loc1 = loc2;
                    }
                    ++loc3;
                }
            }
            return loc1;
        }

        public static isPetCanExtend(arg1: SPetInfo): Boolean
        {
            return arg1 && (arg1.status == EPetStatus._EPetRest || arg1.status == EPetStatus._EPetEquip);
        }

        public static getGrowthTitle(arg1: int): TPetUpgrage
        {
            var loc1=null;
            var loc3=null;
            var loc2=PetUpgradeConfig.instance.growList;
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                loc3 = loc2[loc4];
                if (arg1 < loc3.needNum) 
                {
                    if (loc2[(loc4 - 1)]) 
                    {
                        loc1 = loc2[(loc4 - 1)];
                        break;
                    }
                    else 
                    {
                        break;
                    }
                }
                else if (arg1 != loc3.needNum) 
                {
                    if (loc2[loc4 + 1] == null) 
                    {
                        loc1 = loc3;
                        break;
                    }
                }
                else 
                {
                    loc1 = loc3;
                    break;
                }
                ++loc4;
            }
            return loc1;
        }

        public static getSpiritTitle(arg1: int): TPetUpgrage
        {
            var loc1=null;
            var loc3=null;
            var loc2=PetUpgradeConfig.instance.spiritList;
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                loc3 = loc2[loc4];
                if (arg1 < loc3.needNum) 
                {
                    if (loc2[(loc4 - 1)]) 
                    {
                        loc1 = loc2[(loc4 - 1)];
                        break;
                    }
                    else 
                    {
                        break;
                    }
                }
                else if (arg1 != loc3.needNum) 
                {
                    if (loc2[loc4 + 1] == null) 
                    {
                        loc1 = loc3;
                        break;
                    }
                }
                else 
                {
                    loc1 = loc3;
                    break;
                }
                ++loc4;
            }
            return loc1;
        }

        public static getPetTitle(arg1: int, arg2: int): string
        {
            var loc1="";
            var loc2=PetUtil.getGrowthTitle(arg1);
            var loc3;
            if (loc3 = PetUtil.getSpiritTitle(arg2)) 
            {
                loc1 = loc1 + HTMLUtil.addColor(loc3.title, ColorConfig.instance.getItemColorString(loc3.color));
            }
            if (loc2) 
            {
                loc1 = loc1 + HTMLUtil.addColor(loc2.title, ColorConfig.instance.getItemColorString(loc2.color));
            }
            return loc1;
        }

        public static getPetTitleTipData(arg1: int, arg2: int): string
        {
            var loc1=HTMLUtil.addColor(Language.getString(54106), GlobalStyle.color6);
            var loc2=PetUtil.getGrowthTitleTipData(arg1);
            var loc3=PetUtil.getSpiritTitleTipData(arg2);
            loc1 = loc1 + loc3;
            loc1 = loc1 + "\n";
            loc1 = loc1 + HTMLUtil.addColor(Language.getString(54107), GlobalStyle.color6);
            loc1 = loc1 + loc2;
            return loc1;
        }

        public static getGrowthTitleTipData(arg1: int): string
        {
            var loc4=null;
            var loc1="";
            var loc2=PetUtil.getGrowthTitle(arg1);
            var loc3=PetUpgradeConfig.instance.growList;
            var loc5="#B1efff";
            var loc6=0;
            while (loc6 < loc3.length) 
            {
                loc4 = loc3[loc6];
                if (loc2 && loc2.type == loc4.type && loc2.needNum == loc4.needNum) 
                {
                    loc5 = ColorConfig.instance.getItemColorString(loc2.color);
                    loc1 = loc1 + HTMLUtil.addColor(Language.getStringByParam(54108, loc4.title, loc4.needNum), loc5);
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(54109) + loc4.addNum + "</b>\n", loc5);
                }
                else 
                {
                    loc5 = "#B1efff";
                    loc1 = loc1 + HTMLUtil.addColor(Language.getStringByParam(54108, loc4.title, loc4.needNum), loc5);
                    loc1 = loc1 + HTMLUtil.addColor(Language.getString(54109) + loc4.addNum + "\n", loc5);
                }
                ++loc6;
            }
            return "<textFormat leading=\'5\'>" + loc1 + "</textFormat>";
        }

        public static getSpiritTitleTipData(arg1: int): string
        {
            var loc4=null;
            var loc1="";
            var loc2=PetUtil.getSpiritTitle(arg1);
            var loc3=PetUpgradeConfig.instance.spiritList;
            var loc5="#B1efff";
            var loc6=0;
            while (loc6 < loc3.length) 
            {
                loc4 = loc3[loc6];
                if (loc2 && loc2.type == loc4.type && loc2.needNum == loc4.needNum) 
                {
                    loc5 = ColorConfig.instance.getItemColorString(loc2.color);
                    loc1 = loc1 + HTMLUtil.addColor("<b>" + loc4.title + Language.getStringByParam(54110, loc4.needNum), loc5);
                    loc1 = loc1 + HTMLUtil.addColor(Language.getStringByParam(54111, loc4.addNum), loc5);
                }
                else 
                {
                    loc5 = "#B1efff";
                    loc1 = loc1 + HTMLUtil.addColor(loc4.title + Language.getStringByParam(54110, loc4.needNum), loc5);
                    loc1 = loc1 + HTMLUtil.addColor(Language.getStringByParam(54111, loc4.addNum), loc5);
                }
                ++loc6;
            }
            return "<textFormat leading=\'5\'>" + loc1 + "</textFormat>";
        }

        public static getColorGrowth(arg1: int): string
        {
            return HTMLUtil.addColor(arg1.toString(), PetUtil.getGrowthTitleColor(arg1));
        }

        public static getColorSpirit(arg1: int): string
        {
            return HTMLUtil.addColor(arg1.toString(), PetUtil.getSpiritTitleColor(arg1));
        }

        public static getGrowthTitleColor(arg1: int): string
        {
            var loc1="#B1efff";
            var loc2=PetUtil.getGrowthTitle(arg1);
            if (loc2) 
            {
                loc1 = ColorConfig.instance.getItemColorString(loc2.color);
            }
            return loc1;
        }

        public static getSpiritTitleColor(arg1: int): string
        {
            var loc1="#B1efff";
            var loc2=PetUtil.getSpiritTitle(arg1);
            if (loc2) 
            {
                loc1 = ColorConfig.instance.getItemColorString(loc2.color);
            }
            return loc1;
        }

        public static getGrowthTitleByGrade(arg1: int): TPetUpgrage
        {
            return PetUpgradeConfig.instance.getInfoByGrade(EPetUpgradeType._EPetUpgradeTypeGrowth, arg1);
        }

        public static getSpiritTitleByGrade(arg1: int): TPetUpgrage
        {
            return PetUpgradeConfig.instance.getInfoByGrade(EPetUpgradeType._EPetUpgradeTypeSpirit, arg1);
        }

        public static getTitleByGrade(arg1: int, arg2: int, arg3: string="·"): string
        {
            var loc1="";
            var loc2=PetUtil.getSpiritTitleByGrade(arg1);
            var loc3=PetUtil.getGrowthTitleByGrade(arg2);
            if (loc2) 
            {
                loc1 = HTMLUtil.addColor(loc2.title, ColorConfig.instance.getItemColorString(loc2.color));
            }
            if (loc3) 
            {
                if (loc1 != "") 
                {
                    loc1 = loc1 + ("<font size=\'15\'>" + arg3 + "</font>");
                }
                loc1 = loc1 + HTMLUtil.addColor(loc3.title, ColorConfig.instance.getItemColorString(loc3.color));
            }
            return loc1;
        }

        public static getShowModelId(arg1: SPetInfo): int
        {
            var loc1=0;
            var loc4=0;
            var loc2=arg1.modelLevel;
            if (loc2 == 5) 
            {
                loc2 = 0;
            }
            var loc3;
            if (loc3 = PetConfig.instance.getInfoByCode(arg1.changeCode)) 
            {
                loc4 = loc3.effect;
            }
            var loc5=PetUpgradeModelConfig.instance.getInfoByCode(loc4);
            if (!(loc2 == 0) && loc5) 
            {
                if (loc2 != EPetGrowthGrade._EPetGrowthGradeOne) 
                {
                    if (loc2 != EPetGrowthGrade._EPetGrowthGradeTwo) 
                    {
                        if (loc2 != EPetGrowthGrade._EPetGrowthGradeThree) 
                        {
                            if (loc2 == EPetGrowthGrade._EPetGrowthGradeFour) 
                            {
                                loc1 = loc5.gradefour;
                            }
                        }
                        else 
                        {
                            loc1 = loc5.gradethree;
                        }
                    }
                    else 
                    {
                        loc1 = loc5.gradetwo;
                    }
                }
                else 
                {
                    loc1 = loc5.gradeone;
                }
            }
            else if (loc3) 
            {
                loc1 = int(loc3.modelId);
            }
            return loc1;
        }

        public static getPetUpgradeModel(arg1: SPetInfo): TPetUpgradeModel
        {
            var loc1=0;
            var loc4=0;
            var loc2=arg1.modelLevel;
            if (loc2 == 5) 
            {
                loc2 = 0;
            }
            var loc3;
            if (loc3 = PetConfig.instance.getInfoByCode(arg1.changeCode)) 
            {
                loc4 = loc3.effect;
            }
            return PetUpgradeModelConfig.instance.getInfoByCode(loc4);
        }

        public static isPetCanApply(arg1: SPetInfo): Boolean
        {
            return (arg1.reinLevel == 0 && arg1.level >= 40 || arg1.reinLevel > 0) && arg1.talent >= 601 && arg1.growth >= 24 && arg1.spirit >= 10;
        }

        public static getUpgradeColor(arg1: Boolean, arg2: int): string
        {
            var loc1="#f0ea3f";
            if (arg1) 
            {
                if (arg2 >= 24 && arg2 < 33) 
                {
                    loc1 = "#00BEFF";
                }
                else if (arg2 >= 33 && arg2 < 37) 
                {
                    loc1 = "#FF00FF";
                }
                else if (arg2 >= 37) 
                {
                    loc1 = "#FF7902";
                }
            }
            else if (arg2 >= 10 && arg2 < 15) 
            {
                loc1 = "#00BEFF";
            }
            else if (arg2 >= 15 && arg2 < 19) 
            {
                loc1 = "#FF00FF";
            }
            else if (arg2 >= 19) 
            {
                loc1 = "#FF7902";
            }
            return loc1;
        }

        public static getProtectDict(arg1: Boolean): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc2=0;
            var loc5=null;
            var loc6=null;
            var loc7=0;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            if (arg1) 
            {
                loc2 = 90;
            }
            else 
            {
                loc2 = 91;
            }
            var loc3;
            var loc4=(loc3 = ItemConfig.instance.getTItemUpdateById(loc2)).condition.split("#");
            var loc8=0;
            while (loc8 < loc4.length) 
            {
                loc6 = (loc5 = loc4[loc8] as string).split(",");
                loc7 = int(loc6[0]);
                loc1[loc7] = int(loc6[1]);
                ++loc8;
            }
            return loc1;
        }

        public static getPetTypeName(arg1: SPetInfo): string
        {
            return PetUtil.getPetTypeNameByCareer(arg1.career);
        }

        public static getPetTypeNameByCareer(arg1: int, arg2: Boolean=true): string
        {
            var loc1="";
            if (arg1) 
            {
                if (PetUtil.getCareer(arg1) != ECareer._ECareerPetPhysical) 
                {
                    if (PetUtil.getCareer(arg1) != ECareer._ECareerPetMagic) 
                    {
                        if (PetUtil.getCareer(arg1) == ECareer._ECareerPetPhysique) 
                        {
                            loc1 = Language.getString(54083);
                        }
                    }
                    else 
                    {
                        loc1 = Language.getString(54082);
                    }
                }
                else 
                {
                    loc1 = Language.getString(54081);
                }
                if (arg2) 
                {
                    loc1 = "<font color=\'#f0ea3f\'>" + loc1 + "</font>";
                }
            }
            return loc1;
        }

        public static hasEquips(arg1: SPetInfo): Boolean
        {
            var loc1=null;
            var loc2=0;
            if (arg1.items && arg1.items.length > 0) 
            {
                loc2 = 0;
                while (loc2 < arg1.items.length) 
                {
                    loc1 = new ItemData(arg1.items[loc2] as SPlayerItem);
                    if (ItemsUtil.isPetEquip(loc1)) 
                    {
                        return true;
                    }
                    ++loc2;
                }
            }
            return false;
        }

        public static hasLifeStyle(arg1: SPetInfo): Boolean
        {
            var loc1=null;
            var loc2=0;
            if (arg1.items && arg1.items.length > 0) 
            {
                loc2 = 0;
                while (loc2 < arg1.items.length) 
                {
                    loc1 = new ItemData(arg1.items[loc2] as SPlayerItem);
                    if (ItemsUtil.isPetLifeStyle(loc1)) 
                    {
                        return true;
                    }
                    ++loc2;
                }
            }
            return false;
        }

        public static getTileBitmap(arg1: int, arg2: Boolean): Object /* flash.display.Bitmap */
        {
            var loc1=null;
            var loc2=null;
            if (arg2) 
            {
                loc2 = "PetTitle2" + arg1 + "Label";
            }
            else 
            {
                loc2 = "PetTitle1" + arg1 + "Label";
            }
            loc1 = GlobalClass.getBitmap(loc2);
            return loc1;
        }

        public static getGrowthAddValueArray(arg1: SPetInfo, arg2: int=-1): Array<any>
        {
            var loc1=[];
            var loc2=arg2 == -1 ? arg1.growth : arg2;
            loc1.push(PetAttrCalcUtil.getBaseAttrMutiValue(0, loc2, arg1.level));
            loc1.push(PetAttrCalcUtil.getBaseAttrMutiValue(0, loc2, arg1.level));
            loc1.push(PetAttrCalcUtil.getBaseAttrMutiValue(0, loc2, arg1.level));
            loc1.push(PetAttrCalcUtil.getBaseAttrMutiValue(0, loc2, arg1.level));
            loc1.push(PetAttrCalcUtil.getBaseAttrMutiValue(0, loc2, arg1.level));
            return loc1;
        }

        public static getSpiritAddValueArray(arg1: SPetInfo, arg2: int=-1): Array<any>
        {
            var loc1=[];
            var loc2=arg2 == -1 ? arg1.spirit : arg2;
            loc1.push(PetAttrCalcUtil.getPhysicalAttackMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getMagicAttackMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getPhysicalDefenseMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getMagicDefenseMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getHitMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getJoukMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getCritMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getHitMutiBySpirit(arg1, 0, loc2));
            loc1.push(PetAttrCalcUtil.getHitMutiBySpirit(arg1, 0, loc2));
            loc1.push(0);
            return loc1;
        }

        public static getRebornAddValueArray(arg1: SFightAttribute, arg2: SFightAttribute): Array<any>
        {
            var loc1=[];
            loc1.push(arg2.physicalAttack - arg1.physicalAttack);
            loc1.push(arg2.magicAttack - arg1.magicAttack);
            loc1.push(arg2.physicalDefense - arg1.physicalDefense);
            loc1.push(arg2.magicDefense - arg1.magicDefense);
            loc1.push(arg2.hit - arg1.hit);
            loc1.push(arg2.jouk - arg1.jouk);
            loc1.push(arg2.physicalCrit + arg2.magicCrit - (arg1.physicalCrit + arg1.magicCrit));
            loc1.push(arg2.pass - arg1.pass);
            loc1.push(arg2.toughness - arg1.toughness);
            loc1.push(arg2.relief - arg1.relief);
            loc1.push(arg2.power - arg1.power);
            loc1.push(arg2.agile - arg1.agile);
            loc1.push(arg2.habitus - arg1.habitus);
            loc1.push(arg2.brains - arg1.brains);
            loc1.push(arg2.spiritual - arg1.spiritual);
            return loc1;
        }

        public static isStudySkill(arg1: int, arg2: SPetInfo): Boolean
        {
            var loc1=false;
            var loc2=null;
            var loc3=null;
            var loc4=0;
            if (arg2) 
            {
                loc2 = arg2.skills;
                loc4 = 0;
                while (loc4 < loc2.length) 
                {
                    loc3 = loc2[loc4] as SPetSkill;
                    if (arg1 == loc3.skillId) 
                    {
                        loc1 = true;
                    }
                    ++loc4;
                }
            }
            return loc1;
        }

        public static getShortcutsPetTooltipsData(arg1: SPetInfo): ToolTipInfo
        {
            var loc1="";
            loc1 = loc1 + (PetUtil.getPetName(arg1, false) + "\n");
            loc1 = loc1 + ("<font color=\'#00ff00\'>" + "LV." + arg1.level + " " + PetUtil.getPetTypeName(arg1) + "</font><br>" + "\n");
            loc1 = loc1 + Language.getString(54627);
            return new ToolTipInfo(Tooltip.ToolTipRenderType_ShortcutItem, loc1);
        }

        public static canReborn(arg1: SPetInfo): Boolean
        {
            if (arg1) 
            {
                return arg1.level >= 90;
            }
            return false;
        }

        public static getLevel(arg1: int): int
        {
            if (arg1 < 1000) 
            {
                return arg1;
            }
            return arg1 % 1000;
        }

        public static getFourDigitLevel(arg1: int, arg2: int): int
        {
            if (arg2 < 10) 
            {
                return int(arg1 + "00" + arg2);
            }
            if (arg2 >= 100) 
            {
                return int(arg1 + "" + arg2);
            }
            return int(arg1 + "0" + arg2);
        }

        public static getRebornTimes(arg1: int): int
        {
            return Math.floor(arg1 / 1000);
        }

        public static getRebornTitle(arg1: int): string
        {
            if (arg1 > 0) 
            {
                return "<font size=\'15\'>·</font>" + HTMLUtil.addColor(Language.getStringByParam(28024, GameDefConfig.instance.getChineseNum(arg1)), "#FFFFFF");
            }
            return "";
        }

        public static getCareer(arg1: int): int
        {
            if (arg1 == ECareer._ECareerPetPhysical || arg1 == ECareer._ECareerPetHighPhysical || arg1 == ECareer._ECareerPetSecondPhysical || arg1 == ECareer._ECareerPetThirdPhysical) 
            {
                return ECareer._ECareerPetPhysical;
            }
            if (arg1 == ECareer._ECareerPetMagic || arg1 == ECareer._ECareerPetHighMagic || arg1 == ECareer._ECareerPetSecondMagic || arg1 == ECareer._ECareerPetThirdMagic) 
            {
                return ECareer._ECareerPetMagic;
            }
            if (arg1 == ECareer._ECareerPetPhysique || arg1 == ECareer._ECareerPetHighPhysique || arg1 == ECareer._ECareerPetSecondPhysique || arg1 == ECareer._ECareerPetThirdPhysique) 
            {
                return ECareer._ECareerPetPhysique;
            }
            return 0;
        }

        public static getPetCareer(arg1: int): int
        {
            if (arg1 == ECareer._ECareerPetMagic || arg1 == ECareer._ECareerPetHighMagic || arg1 == ECareer._ECareerPetSecondMagic || arg1 == ECareer._ECareerPetThirdMagic) 
            {
                return ECareer._ECareerPetMagic;
            }
            return 2560;
        }

        public static getEqStrengthAmount(arg1: int, arg2: string): int
        {
            var loc1=null;
            var loc2=0;
            var loc3=null;
            if (arg2 != GModuleEvent.Mode_Self) 
            {
                loc1 = PetUtil.otherEquipments;
            }
            else 
            {
                loc1 = PetUtil.selfEquipments;
            }
            var loc4=0;
            var loc5=0;
            while (loc5 < loc1.length) 
            {
                if ((loc3 = loc1[loc5]) && loc3.itemInfo) 
                {
                    if ((loc4 = PlayerEqStrengthInfo.getStrengthen(loc3)) >= arg1) 
                    {
                        ++loc2;
                    }
                }
                ++loc5;
            }
            return loc2;
        }

        public static getAttr(arg1: Array<any>): Map<any, any> /* flash.utils.Dictionary */
        {
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc7=0;
            var loc1=new Map<any, any> /* flash.utils.Dictionary */();
            var loc2=arg1.length;
            var loc3=0;
            while (loc3 < loc2) 
            {
                loc6 = (loc4 = String(arg1[loc3]).split("#")).length;
                loc7 = 0;
                while (loc7 < loc6) 
                {
                    loc5 = String(loc4[loc7]).split(",");
                    loc1[loc5[0]] = int(loc1[loc5[0]]) + int(loc5[1]);
                    ++loc7;
                }
                ++loc3;
            }
            return loc1;
        }

        public static isOwnPetByItemData(arg1: ItemData): Boolean
        {
            var loc2=null;
            var loc3=null;
            var loc7=0;
            var loc9=null;
            var loc10=null;
            var loc11=undefined;
            var loc1=false;
            var loc4="";
            if (loc3 = PetConfig.instance.getItemInfoByCode(arg1.effect)) 
            {
                loc4 = loc3.pet.modelId;
            }
            var loc5;
            var loc6=(loc5 = (loc5 = (loc5 = (loc5 = []).concat(Cache.instance.pack.backPackCache.getTypeItems(ECategory._ECategoryProp, EProp._EPropPetEgg))).concat(Cache.instance.pack.wareHousePackCache.getTypeItems(ECategory._ECategoryProp, EProp._EPropPetEgg))).concat(Cache.instance.pack.treasurePackCache.getTypeItems(ECategory._ECategoryProp, EProp._EPropPetEgg))).length;
            loc7 = 0;
            while (loc7 < loc6) 
            {
                loc2 = loc5[loc7];
                if (loc2) 
                {
                    if ((loc3 = PetConfig.instance.getItemInfoByCode(loc2.effect)) && loc3.pet.modelId == loc4) 
                    {
                        loc1 = true;
                        break;
                    }
                }
                ++loc7;
            }
            if (!loc1) 
            {
                if (loc9 = Cache.instance.pet.petModelList) 
                {
                    loc10 = loc9.modelList;
                    var loc12=0;
                    var loc13=loc10;
                    for (loc11 in loc13) 
                    {
                        if (!((loc3 = PetConfig.instance.getItemInfoByCode(loc11)) && loc3.pet.modelId == loc4)) 
                        {
                            continue;
                        }
                        loc1 = true;
                        break;
                    }
                }
            }
            var loc8=[];
            if (!loc1) 
            {
                loc8 = Cache.instance.pet.petBag.petInfos;
                loc1 = PetUtil.isOwnByPetInfos(loc8, loc4);
            }
            if (!loc1) 
            {
                loc8 = Cache.instance.petWareHouse.petBag.petInfos;
                loc1 = PetUtil.isOwnByPetInfos(loc8, loc4);
            }
            return loc1;
        }

        /* internal  */static isOwnByPetInfos(arg1: Array<any>, arg2: string): Boolean
        {
            var loc2=null;
            var loc3=null;
            var loc1=false;
            var loc4=arg1.length;
            var loc5=0;
            while (loc5 < loc4) 
            {
                loc3 = null;
                if ((loc2 = arg1[loc5]) && !loc2.isBorrow) 
                {
                    loc3 = PetConfig.instance.getInfoByCode(loc2.code);
                }
                if (loc3 && loc3.modelId == arg2) 
                {
                    loc1 = true;
                    break;
                }
                ++loc5;
            }
            return loc1;
        }

        public static getOffset(arg1: int, arg2: int, arg3: int): int
        {
            var loc1=0;
            var loc2;
            return loc1 = (loc2 = PetBloodLineConfig.instance.getNum(arg1, arg2, arg3)) != 1 ? 35 : -35;
        }

        public static getColorByQuality(arg1: int): int
        {
            if (arg1 >= 1 && arg1 <= 3) 
            {
                return 1;
            }
            if (arg1 >= 4 && arg1 <= 6) 
            {
                return 2;
            }
            if (arg1 >= 7 && arg1 <= 9) 
            {
                return 3;
            }
            return 4;
        }

        public static getAllIndexAttr(arg1: int, arg2: int, arg3: int, arg4: int): string
        {
            var loc2=null;
            var loc3=null;
            var loc1=[];
            var loc4=Cache.instance.role.entityInfo.career;
            var loc5=PetBloodLineConfig.instance.getName(arg1);
            var loc6=PetBloodLineConfig.instance.getPositionName(arg1, arg3);
            var loc7=PetBloodLineConfig.instance.getTierName(arg2);
            var loc8=1;
            while (loc8 <= arg2) 
            {
                if (loc8 != arg2) 
                {
                    loc1.push(PetBloodLineConfig.instance.getAttr(arg1, loc8, arg3));
                }
                else if (arg3 <= arg4) 
                {
                    loc1.push(PetBloodLineConfig.instance.getAttr(arg1, loc8, arg3));
                }
                ++loc8;
            }
            if (loc3 = (loc2 = EquipmentUtil.getSelfCareerAttribute(loc4, PetUtil.getAttr(loc1)))[0] as DefInfo) 
            {
                return Language.getStringByParam(28508, loc5, loc6, loc7, loc3.name, loc3.value);
            }
            return "";
        }

        public static getAddAttr(arg1: int, arg2: int, arg3: int): string
        {
            var loc4=null;
            var loc7=null;
            var loc8=0;
            var loc9=0;
            var loc13=null;
            var loc14=null;
            var loc15=0;
            var loc1="";
            var loc2=[];
            var loc3=[];
            var loc5="";
            var loc6="";
            var loc10=Cache.instance.role.entityInfo.career;
            var loc11=PetBloodLineConfig.instance.getName(arg1);
            var loc12=PetBloodLineConfig.instance.getRealmAndLevel(arg1);
            loc1 = loc1 + (Language.getStringByParam(28513, loc12.realm + loc12.lv) + "<br><br>");
            loc9 = 1;
            while (loc9 <= arg2) 
            {
                if (loc9 == arg2 && arg3 < 8) 
                {
                    if ((loc14 = PetBloodLineConfig.instance.getAddAttr(arg1, loc9)) != "") 
                    {
                        loc3.push(loc14);
                    }
                }
                else 
                {
                    loc2.push(PetBloodLineConfig.instance.getAddAttr(arg1, loc9));
                }
                ++loc9;
            }
            if (loc2.length > 0) 
            {
                loc15 = arg2 < 9 ? (loc15 - 1) : arg2;
                loc8 = (loc4 = EquipmentUtil.getSelfCareerAttribute(loc10, PetUtil.getAttr(loc2))).length;
                loc13 = PetBloodLineConfig.instance.getTierName(loc15);
                loc5 = loc5 + (Language.getStringByParam(28509, loc12.lv + " (" + loc11 + ")") + "<br><br>");
                loc6 = loc6 + "<br>";
                loc9 = 0;
                while (loc9 < loc8) 
                {
                    if (loc7 = loc4[loc9] as DefInfo) 
                    {
                        loc5 = loc5 + (HTMLUtil.addColor("   " + loc7.name + "  +" + loc7.value, GlobalStyle.color6) + "<br>");
                    }
                    ++loc9;
                }
            }
            if (loc3.length > 0) 
            {
                loc8 = (loc4 = EquipmentUtil.getSelfCareerAttribute(loc10, PetUtil.getAttr(loc2.concat(loc3)))).length;
                loc13 = PetBloodLineConfig.instance.getTierName(arg2);
                loc6 = loc6 + (Language.getStringByParam(28510, loc12.lv + loc13, (arg3 - 1)) + "<br>");
                loc9 = 0;
                while (loc9 < loc8) 
                {
                    if (loc7 = loc4[loc9] as DefInfo) 
                    {
                        loc6 = loc6 + (HTMLUtil.addColor("   " + loc7.name + "  +" + loc7.value, "#8C8C8C") + "<br>");
                    }
                    ++loc9;
                }
            }
            return loc1 + loc5 + loc6;
        }

        public static get activeItemCodes(): Array<any>
        {
            var loc5=null;
            var loc6=null;
            var loc7=null;
            var loc8=null;
            var loc1=[];
            var loc2=Cache.instance.active.getActiveListByCode(EActiveType._EActiveTypePetBloodLineUpgrade);
            var loc3=loc2.length;
            var loc4=0;
            while (loc4 < loc3) 
            {
                if (loc5 = loc2[loc4]) 
                {
                    loc8 = (loc7 = (loc6 = JSONHelper.deserialize(loc5.modulus)).code).slice(0, (loc7.length - 1)) + (int(loc7.charAt((loc7.length - 1))) - 1);
                    loc1.push(int(loc7));
                    loc1.push(int(loc8));
                }
                ++loc4;
            }
            return loc1;
        }

        public static get maxSPetBlood(): SPetBlood
        {
            if (!PetUtil._maxSPetBlood) 
            {
                PetUtil._maxSPetBlood = new SPetBlood();
            }
            PetUtil._maxSPetBlood.curCategory = PetUtil.MAX_CATEGORY;
            PetUtil._maxSPetBlood.curQuality = 9;
            PetUtil._maxSPetBlood.curType = 8;
            return PetUtil._maxSPetBlood;
        }

        public static /* const */MAX_CATEGORY: int=27;

        public static /* var */curUseBloodItemCode: int=0;

        public static /* var */selfEquipments: Array<any>;

        public static /* var */otherEquipments: Array<any>;

        /* internal */ static /* var */_maxSPetBlood: SPetBlood;
    }
